//
//  wishCell.m
//  TinyFortune
//
//  Created by lc on 16/6/23.
//  Copyright © 2016年 lc. All rights reserved.
//

#import "wishCell.h"
#import "AVFile +  getDictionary.h"

@implementation wishCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
- (void)layoutSubviews{
    self.backerView.backgroundColor = [UIColor colorWithRed:239/255.0f green:239/255.0f blue:244/255.0f alpha:1];
}

- (void)setModel:(wishModel *)model{
    _model = model ;
    
 [AVFile getFileWithObjectId:_model.file withBlock:^(AVFile *file, NSError *error) {
     NSDictionary *dict = [AVFile fileWithDictionary:file];
     [self.wishImageView sd_setImageWithURL:[NSURL URLWithString:dict[@"url"] ] ];
     self.titleLabel.text = _model.title;
     self.desc.text = _model.desc ;
    }];
    
    AVUser *currentUser = [AVUser currentUser];
    if ([currentUser.mobilePhoneNumber isEqualToString:self.model.user]) {
        self.heartImageView.image = [[UIImage imageNamed:@"blueHeart"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
        self.smallHeart.image = [[UIImage imageNamed:@"blueHeart"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    }else{
        self.heartImageView.image = [[UIImage imageNamed:@"redHeart"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
        self.smallHeart.image = [[UIImage imageNamed:@"redHeart"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    }

}

@end
